<template>
    <a-modal :title="$t('修复节点')" v-model='isShow' width='480px' :maskClosable='false' v-dragModal :footer="null" :closable="false">
        <a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
            <a-spin :spinning="loading">
                <div v-if="status" style="text-align: center;">
                    <div> {{ $t('Node') }} {{ form.node }} {{ $t('Repair-success') }}</div>
                    <a-button style="margin-top: 8px;" type="primary" @click="handleClose">
                        {{ $t('Sure') }}
                    </a-button>
                </div>
                <div v-else style="text-align: center;">
                    <div>{{ $t('Node') }} {{ form.node }} {{ $t('Repair-fail') }} {{ $t('错误信息') }} ：{{ reason }}</div>
                    <a-button style="margin-top: 8px;" type="primary" @click="handleClose">
                        {{ $t('Sure') }}
                    </a-button>
                </div>
            </a-spin>
        </a-form-model>
    </a-modal>
</template>

<script>
export default {
    data() {
        return {
            isShow: false,
            loading: false,
            labelCol: { span: 6 },
            wrapperCol: { span: 18 },
            form: {
                node: '',
                share_id: '',
            },
            rules: {
            },
            status: '',
            reason: '',
        };
    },
    watch: {
        async isShow(value) {
            if (value) {
                this.loading = true
                const { data } = await this.$api.directory.repairShareApi({ node: this.form.node, share_id: this.form.share_id })
                // this.model(data.id) //返回模板
                // this.notice(data.id, data.params, data.flag) //通知列表显示
                if (data.flag == '0') {
                    this.status = true
                    this.$emit('get-list', this.form.share_id)
                } else {
                    this.status = false
                    this.reason = data.msg
                }
                this.loading = false
            }
        }
    },
    computed: {
        taskNameList() {
            return this.$store.state.basetips
        }
    },
    methods: {
        handleClose() {
            this.$refs['ruleForm'].resetFields();
            this.isShow = false
        },
    }
}
</script>
